<?php
	$txtsearch=$_GET['keyword'];

	$obj=new Post();
	$data = $obj->getTable(" WHERE Title like '%".$txtsearch."%' OR Summary like '%".$txtsearch."%' OR Detail like '%".$txtsearch."%' ORDER BY `post`.`LastUpdate` DESC");
	
	$paging=true;
	$display=10;
	
	/*******Start Paging*****************************/
	$page = $_GET['page'];				
	$limit = $display; 
	$total = count($data); 
	// work out the pager values 
	$pager  = Pager::getPagerData($total, $limit, $page); 
	$offset = $pager->offset; 
	$limit  = $pager->limit; 
	$page   = $pager->page;
	/*******Break paging*******************************/
?>

<div class="ben-section">
    <div class=" ben-section-title">Tìm kiếm sản phẩm</div>
    
    <div class=" ben-section-content">	
        <h2>Kết quả tìm kiếm với từ khóa: <?php echo $txtsearch?></h2>
        <?php
	for($i=$offset;$i<$offset+$limit && count($data[$i])>0;$i++)
	{
		$item=$data[$i];
		
		$obj = new Menu();
		$obj->loadByKeyLang($item['NewsTypeID'],$lang);
	?>
    <div class="ben-post">
        <?php if($item['ImageID'] != 0){ ?>
        <a class="islink" href="<?php echo $obj->createLink($obj,$lang).$item['PostID'] ?>">
            <img src='<?php echo $img->resizePNG($item['ImagePath'],170,170)?>' class='ben-left' />
        </a>
        <?php }?>
        <a href="<?php echo $obj->createLink($obj,$lang).$item['PostID'] ?>"><h3><?php echo $item['Title'.$lang]?></h3></a>
        
        <div class="ben-post-body">
            <p><?php echo $item['Summary'.$lang]?></p>
        </div>
        <div class="clearer">&nbsp;</div>
    </div>
    <?php } ?>   
    <?php
	  include("module/common/pagination.php");
	  ?>     
        <div class="clearer">&nbsp;</div>        
    </div>
</div>